package com.xinfu.newproject.adapter.paycost_provider;

import android.widget.Toast;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.xinfu.newproject.R;
import com.xinfu.newproject.adapter.paycost_adapter.PayCostAdapter;
import com.xinfu.newproject.bean.paycost.PayCostBean;
import com.xinfu.newproject.entity.NormalMultipleEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * https://github.com/chaychan
 *
 * @author ChayChan
 * @description: Img ItemProvider
 * @date 2018/3/30  11:39
 */

public class PayCostThreeProvider extends BaseItemProvider<NormalMultipleEntity, BaseViewHolder> {

    private RecyclerView mRecyclerView;

    private PayCostAdapter payCostAdapter;

    @Override
    public int viewType() {
        return PayCostMultipleItemRvAdapter.TYPE_PAYCOST_THREE;
    }

    @Override
    public int layout() {
        return R.layout.item_pay_cost_three;
    }

    @Override
    public void convert(BaseViewHolder helper, NormalMultipleEntity data, int position) {
        mRecyclerView = helper.getView(R.id.item_pay_cost_three_rv);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        mRecyclerView.setFocusableInTouchMode(false);
        mRecyclerView.requestFocus();
        initAdapter();

        mRecyclerView.setAdapter(payCostAdapter);

    }


    private void initAdapter() {
        List<PayCostBean> payCostBeanList = new ArrayList<>();
        PayCostBean payCostBean = new PayCostBean();
        payCostBean.setCostName("车位费");
        payCostBean.setCostType(2);
        PayCostBean payCostBean1 = new PayCostBean();
        payCostBean1.setCostName("物业费");
        payCostBean1.setCostType(1);
        payCostBeanList.add(payCostBean);
        payCostBeanList.add(payCostBean1);
        payCostAdapter = new PayCostAdapter(mContext, payCostBeanList);
    }
    @Override
    public void onClick(BaseViewHolder helper, NormalMultipleEntity data, int position) {
        Toast.makeText(mContext, "click", Toast.LENGTH_SHORT).show();
    }

    @Override
    public boolean onLongClick(BaseViewHolder helper, NormalMultipleEntity data, int position) {
        Toast.makeText(mContext, "longClick", Toast.LENGTH_SHORT).show();
        return true;
    }
}
